package com.mystyle.le.weekproject.adapter;

import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.mystyle.le.weekproject.R;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.List;

/**
 * 数据库的自定义适配器
 * Created by le on 2016/10/14.
 */
public class CuttorCostorAdapteri extends CursorAdapter {

    public CuttorCostorAdapteri(Context context, Cursor c) {
        super(context, c);
    }


    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        return LayoutInflater.from(context).inflate(R.layout.cuttor_adapter_layout,parent,false);
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {
//        ViewHolder holder = null;
        ImageView seniority_iv = (ImageView) view.findViewById(R.id.seniority_iv2);
        TextView name_tv = (TextView) view.findViewById(R.id.name_tv2);
        TextView ranking_tv = (TextView) view.findViewById(R.id.ranking_tv2);
        TextView state_tv = (TextView) view.findViewById(R.id.state_tv2);
        TextView theme_tv = (TextView) view.findViewById(R.id.theme_tv2);

       name_tv.setText(cursor.getString(cursor.getColumnIndex("name")));
        ranking_tv.setText("人气： "+cursor.getString(cursor.getColumnIndex("ranking")));
       state_tv.setText("状态： "+cursor.getString(cursor.getColumnIndex("state")));
        theme_tv.setText("类别： "+cursor.getString(cursor.getColumnIndex("id1")));
        String icon = cursor.getString(cursor.getColumnIndex("icon"));
        Picasso.with(context).load(icon).into(seniority_iv);
    }
//    class ViewHolder{
//        ImageView seniority_iv;
//        TextView name_tv,ranking_tv,state_tv,theme_tv;
//    }
}
